<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
	</head>
	<body>
		<script>
			// 输入m，求n，使n!<=m<(n+1)! 例如，输入726，应输出n=6
			
			// while实现阶乘
			function sum(num){
				let s = 1;//计数器，判断递归循环到的数是否等于传进来的值
				let total = 1;//总数
				if(num == 1){
					return 1;
				}
				while(s < num){
					total = total * (s + 1);
					s += 1;
				}
				return total;
			}
			
			// 主函数
			function main(number){
				let n = 1;
				let f = true;
				while(f){
					if(sum(n) <= number && number < sum(n+1)){
						f = false;
					}else{
						n += 1;
					}
				}
				return n;
			}
			console.log(main(726));
			
		</script>
	</body>
</html>
